package com.example.doctorserver.controller;



import com.example.doctorserver.dto.OrdersPageResponseDTO;
import com.example.doctorserver.dto.SelectForm;
import com.example.doctorserver.pojo.Orders;
import com.example.doctorserver.response.ApiRestResponse;
import com.example.doctorserver.service.OrdersService;
import com.example.doctorserver.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/orders")
public class OrdersController {

    @Autowired
    private SetmealService setmealService;

    @Autowired
    private OrdersService ordersService;


    @PostMapping("/listOrders")
    public ApiRestResponse listOrders(@RequestBody SelectForm selectForm){

//        System.out.println(selectForm.toString());
        OrdersPageResponseDTO dto=ordersService.selectOrderByForm(selectForm);

        return ApiRestResponse.success(dto);
    }

//    归档总检报告
    @PostMapping("/updateOrdersState")
    public ApiRestResponse updateOrdersState(@RequestBody Orders orders){

//        System.out.println(orders.getOrderId()+"----------"+orders.getState());

        int f=ordersService.updateState(orders.getOrderId(),orders.getState());

        return ApiRestResponse.success(f);
    }


}
